package com.googlecode.continuity.core.server.mvc.command;

import com.googlecode.continuity.core.client.ContinuityUser;

/**
 * The EditUserCommand is used to process user account edits. We cannot use the
 * {@link com.googlecode.continuity.core.client.User} class as command since it doesn't support such functionality as
 * old/new password checks.
 *
 * @author Peter Schmitt <aragos@aragos.de>
 * @see com.googlecode.continuity.core.server.mvc.validation.EditAccountValidator
 * @see com.googlecode.continuity.core.server.mvc.controller.EditUserFormController
 */
public class EditUserCommand {
// ------------------------------ FIELDS ------------------------------

  private ContinuityUser user;

  private String oldpass;
  private String newpass1;
  private String newpass2;

// --------------------------- CONSTRUCTORS ---------------------------

  /**
   * Constructs a new command object around the given user.
   *
   * @param user user this command relates to
   */
  public EditUserCommand(ContinuityUser user) {
    this.user = user;
  }

// --------------------- GETTER / SETTER METHODS ---------------------

  /**
   * Returns a new password which the user entered (first field).
   *
   * @return new password (first field)
   */
  public String getNewpass1() {
    return newpass1;
  }

  /**
   * Sets the new password (first field).
   *
   * @param newpass1 new password (first field)
   */
  public void setNewpass1(String newpass1) {
    this.newpass1 = newpass1;
  }

  /**
   * Returns a new password which the user entered (second "check" field).
   * @return new password (second "check" field)
   */
  public String getNewpass2() {
    return newpass2;
  }

  /**
   * Sets the new password (second field).
   *
   * @param newpass2 new password (second field)
   */
  public void setNewpass2(String newpass2) {
    this.newpass2 = newpass2;
  }

  /**
   * Returns the value the user entered in the "old password" field.
   *
   * @return old password
   */
  public String getOldpass() {
    return oldpass;
  }

  /**
   * Sets a new old password value.
   *
   * @param oldpass old password
   */
  public void setOldpass(String oldpass) {
    this.oldpass = oldpass;
  }

  /**
   * Returns the user object this command edits.
   *
   * @return user object
   */
  public ContinuityUser getUser() {
    return user;
  }

  /**
   * Sets a new user object for this command to edit.
   *
   * @param user new user object
   */
  public void setUser(ContinuityUser user) {
    this.user = user;
  }
}
